package com.atguigu.d_change;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class Demo {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String str1 = "abc";

        //转字符数组
        char[] chs = str1.toCharArray();
        System.out.println("Arrays.toString(chs) = " + Arrays.toString(chs));

        //转字节数组 -> 编码
        byte[] bys1 = str1.getBytes();
        System.out.println("Arrays.toString(bys1) = " + Arrays.toString(bys1));

        byte[] bys2 = str1.getBytes("GBK");
        System.out.println("Arrays.toString(bys2) = " + Arrays.toString(bys2));

        //中文在不同编码表下占用的字节数不一样
        String str2 = "我爱你";
        byte[] bys3 = str2.getBytes(); //UTF-8
        System.out.println("Arrays.toString(bys3) = " + Arrays.toString(bys3));//

        byte[] bys4 = str2.getBytes("GBK"); //GBK
        System.out.println("Arrays.toString(bys4) = " + Arrays.toString(bys4));//

        System.out.println("---------------------------------");

        String str3 = "HelloWorld";

        String lowerCase = str3.toLowerCase();

        System.out.println("str3 = " + str3);
        System.out.println("lowerCase = " + lowerCase);

        String upperCase = str3.toUpperCase();
        System.out.println("upperCase = " + upperCase);

    }
}
